<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">

      <el-form-item label="申请类型" prop="jrProductType">
        <el-select v-model="queryParams.jrProductType" placeholder="请选择" clearable>
          <el-option
            v-for="dict in dict.type.financial_apply_type"
            :label="dict.label"
            :value="dict.value"></el-option>
        </el-select>
      </el-form-item>

      <el-form-item label="申请状态" prop="applyState">
        <el-select v-model="queryParams.applyState" placeholder="请选择" clearable>
          <el-option
            v-for="dict in dict.type.financial_apply_state"
            :label="dict.label"
            :value="dict.value"></el-option>
        </el-select>
      </el-form-item>
      <br>

      <el-form-item label="查询日期" prop="createTime">
        <el-date-picker clearable
          v-model="queryParams.leftTime"
          type="date"
          value-format="yyyy-MM-dd"
          format="yyyy-MM-dd"
          placeholder="时间左区间">
        </el-date-picker>
        至
      </el-form-item>
      <el-form-item prop="createTime">
        <el-date-picker clearable
                        v-model="queryParams.rightTime"
                        type="date"
                        value-format="yyyy-MM-dd"
                        format="yyyy-MM-dd"
                        placeholder="时间右区间">
        </el-date-picker>
      </el-form-item>

      <el-form-item>
        <el-button type="primary"
                   icon="el-icon-search"
                   v-hasPermi="['finance:installment:query']"
                   size="mini"
                   @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">

      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['finance:installment:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="installmentList">
      <el-table-column label="申请合同号" align="center" prop="rentInstallmentOrderNo" />
      <el-table-column label="贷款信息" align="center" prop="loanMessage" />
      <el-table-column label="申请类型" align="center" prop="jrProductType" />
      <el-table-column label="借款金额" align="center" prop="loanAmount" >
        <template slot-scope="scope">{{scope.row.loanAmount}}元</template>
      </el-table-column>
      <el-table-column label="借款期限" align="center" prop="monthLimit">
      <template slot-scope="scope">{{scope.row.monthLimit}}个月</template>
      </el-table-column>
      <el-table-column label="申请日期" align="center" prop="createTime" />
      <el-table-column label="资金方" align="center" prop="companyName" />
      <el-table-column label="申请状态" align="center" prop="applyStateName" />
      <el-table-column label="驳回原因" align="center" prop="auditMemo" />
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { listInstallment, getInstallment, delInstallment, addInstallment, updateInstallment } from "@/api/finance/installment";

export default {
  name: "Installment",
  dicts: ['financial_apply_type','financial_apply_state'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 房租分期申请表格数据
      installmentList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        jrProductType: null,
        applyState: null,
        leftTime: null,
        rightTime: null,
      },
      // 表单参数
      form: {},

    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询房租分期申请列表 */
    getList() {
      this.loading = true;
      listInstallment(this.queryParams).then(response => {
        this.installmentList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('finance/installment/export', {
        ...this.queryParams
      }, `installment_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
